<?php

/**
 * This is the model class for table "{{membership}}".
 *
 * The followings are the available columns in table '{{membership}}':
 * @property double $membership_id
 * @property string $membership_name
 * @property string $membership_code
 * @property double $edu_type
 * @property double $listorder
 * @property double $disabled
 * @property double $create_user
 * @property double $create_time
 * @property double $update_user
 * @property double $update_time
 * @property string $description
 * @property double $is_del
 */
class Membership extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Membership the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return '{{membership}}';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('edu_type, listorder, disabled, create_user, create_time, update_user, update_time, is_del', 'numerical'),
			array('membership_name', 'length', 'max'=>50),
			array('membership_code', 'length', 'max'=>20),
			array('description', 'length', 'max'=>4000),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('membership_id, membership_name, membership_code, edu_type, listorder, disabled, create_user, create_time, update_user, update_time, description, is_del', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'membership_id' => 'Membership',
			'membership_name' => 'Membership Name',
			'membership_code' => 'Membership Code',
			'edu_type' => 'Edu Type',
			'listorder' => 'Listorder',
			'disabled' => 'Disabled',
			'create_user' => 'Create User',
			'create_time' => 'Create Time',
			'update_user' => 'Update User',
			'update_time' => 'Update Time',
			'description' => 'Description',
			'is_del' => 'Is Del',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('membership_id',$this->membership_id);
		$criteria->compare('membership_name',$this->membership_name,true);
		$criteria->compare('membership_code',$this->membership_code,true);
		$criteria->compare('edu_type',$this->edu_type);
		$criteria->compare('listorder',$this->listorder);
		$criteria->compare('disabled',$this->disabled);
		$criteria->compare('create_user',$this->create_user);
		$criteria->compare('create_time',$this->create_time);
		$criteria->compare('update_user',$this->update_user);
		$criteria->compare('update_time',$this->update_time);
		$criteria->compare('description',$this->description,true);
		$criteria->compare('is_del',$this->is_del);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}